package pers.qianyu.month_202101.date_20210130;

/**
 * 80. 骰子的点数
 * https://www.acwing.com/problem/content/76/
 *
 * @author mizzle rain
 * @date 2021年1月30日22:24:15
 */
public class NumberOfDice {
    public int[] numberOfDice(int n) {
        // dp[i][j] 表示骰子掷 i 次，点数和为 j 的情况有多少种
        int[][] dp = new int[n + 1][6 * n + 1];
        dp[0][0] = 1;
        for (int i = 1; i <= n; i++) {
            for (int j = i; j <= 6 * n; j++) {
                for (int k = 1; k <= Math.min(j, 6); k++) {
                    dp[i][j] += dp[i - 1][j - k];
                }
            }
        }
        int[] res = new int[5 * n + 1];
        for (int i = n, k = 0; i <= 6 * n; i++, k++) res[k] = dp[n][i];
        return res;
    }
}